#ifndef __FLOCK_H
#define __FLOCK_H 1

#include "Agent.h"
#include <vector>

class Crowd
{
public:
	std::vector<Agent *> boids;
	std::vector<Point *> obstacles;
	std::vector<Point *> targets;

	std::vector<Point *> goals;

	Crowd();
	~Crowd();
	float maxVel;
	float maxAcc;
	float avoidDist;
	float neighborDist;

	float avoidWeight;
	float headingWeight;
	float centroidWeight;
	float targetWeight;

	void getCentroid(float *centroid);

	void clear();
	void tick();

	bool ignoreY; // set to true if you don't want stuff to float
private:
	float *avoidBoids(Agent *boid);
	float *approachTargets(Agent *boid);
	float *computeCentroidVel(Agent *boid);
	float *computeVelocities(Agent *boid);
	float solveMagnitude(float magnitude, float acc[3], float newacc[3]);
	float getDist2(Agent *boid1, Agent *boid2);
	bool areNeighbors(Agent *boid1, Agent *boid2);

	void computeAlphaDerivative( Agent* boid, float p[3], float pv[3], float& ad, float &tti, bool verbose = false);
	float computeTau(float tti, float ad);
};

#endif